<template>
  <div class="home">
    <div class="login-container">
      <div class="login-form">
        <h2>登录</h2>
        <form @submit.prevent="login">
          <div class="form-group">
            <label for="username">用户:</label>
            <input type="text" id="username" v-model="username" required>
          </div>
          <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" id="password" v-model="password" required>
          </div>
          <button type="submit">确认</button>
        </form>
      </div>
    </div>
  </div>
</template>
<style lang="scss">
@import '../css/homeView';
</style>
<script>
/* eslint-disable */
import axios from "axios";
import Vue from "vue";

export default {
  name: 'HomeView',
  data() {
    return {
      username: 'admin',
      password: '123456'
    };
  },
  methods: {
    login() {
      if (this.username === "admin" && this.password === "123456") {
        this.$router.push('/report');
      }
      // const data = {username: this.username, password: this.password}
      // console.log('用户:', this.username, '+密码:', this.password);
      // axios.post(this.$demo + '/login', data)
      //     .then(response => {
      //       console.log("返回凭证:",response.data)
      //       if (response.data === true) {
      //         sessionStorage.setItem('login', 'true');
      //         this.$router.push('/report');
      //       } else {
      //         this.$message.error('账号或密码错误');
      //       }
      //     })
      //     .catch(error => {
      //       console.error(error);
      //     });
    },
  }
};
</script>

